<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>工序报工(非扫码)-精工云MES系统平板端</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link href="/JG/Content/jquery/weui/style/weui.min.css" rel="stylesheet" />
    <link href="/JG/Content/jquery/jquery-weui/css/jquery-weui.min.css" rel="stylesheet" />
    <link href="/JG/Content/css/bootstrap.min.css" rel="stylesheet" />
    <link href="/JG/Content/css/Global.css" rel="stylesheet" />
    <link rel="stylesheet" href="/JG/Content/css/BatchSubmittedNo.css?v=1">
    <script src="/JG/Content/LocalConfigs.js?v=1"></script>
    <script src="/JG/Content/LocalUserInfo.js"></script>
</head>

<body>
    <!--title部分-->
    <header class="header">
        <div class="empty">
            <span id="stations"></span>
        </div>
        <div class="header_title">
            <a href="javascript:;">工序报工</a>
        </div>
        <div class="item item2">
            <div class="user_img" onclick="javascript:location.href='/JG/Home/Index.html'">
                <span class="back"><img src="/JG/Content/images/return.png" alt=""></span>
            </div>
        </div>
    </header>

    <div id="MainPage">
        <div class="sec_content">
            <div class="textbox">
                <div class="row centerdiv">
                    <ul class="pro_ul list-group">
                        <!--<li class="list-group-item">-->
                        <!--产线&nbsp;&nbsp;&nbsp;&nbsp;<span>{{FormData.ProdLine}}</span>-->
                        <!--</li>-->
                        <!--<li class="list-group-item">-->
                        <!--工位&nbsp;&nbsp;&nbsp;&nbsp;<span>{{FormData.InvStd}}</span>-->
                        <!--</li>-->
                        <!--<li class="list-group-item">-->
                        <!--<span class="task_title">任务单号</span>-->
                        <!--<span class="task_list">-->
                        <!--<i class="icon-img"></i>-->
                        <!--<input v-bind:value="FormData.TaskCode" class="input_value" type="text" placeholder="点击选择相关信息">-->
                        <!--</span>-->
                        <!--</li>-->
                        <li class="list-group-item">
                            <div class="weui-cell weui-cell_select weui-cell_select-after">
                                <div class="weui-cell__hd">
                                    <label for="" class="weui-label">生产线</label>
                                </div>
                                <div class="weui-cell__bd">
                                    <select class="weui-select" name="select2" placeholder="请选择生产线"
                                        v-model="FormData.BgsjCxbm" @change="ProductionLineChange()">
                                        <option disabled selected value>请选择生产线</option>
                                        <option v-for="(item,index) in ProLineData" v-bind:value="item.CXSJ_CXBM">
                                            {{item.CXSJ_CXMC}}
                                        </option>
                                    </select>
                                </div>
                            </div>
                        </li>
                        <li class="list-group-item">
                            <span class="task_title">订单号</span>
                            <span class="task_list">
                                <input v-bind:value="FormData.OrderCode" type="text" readonly="true">
                            </span>
                        </li>
                        <li class="list-group-item">
                            <span class="task_title">任务单号</span>
                            <span class="task_list">
                                <i class="icon-img"></i>
                                <input v-bind:value="FormData.TaskCode" class="input_value" type="text"
                                    placeholder="点击选择任务单号">
                            </span>
                        </li>
                        <li class="list-group-item">
                            <span class="task_title">产品编号</span>
                            <span class="task_list">
                                <i class="icon-img"></i>
                                <input v-bind:value="FormData.InvCode" class="input_value" type="text"
                                    placeholder="点击选择相关信息">
                            </span>
                        </li>
                        <li class="list-group-item">
                            <span class="task_title">产品名称</span>
                            <span class="task_list">
                                <i class="icon-img"></i>
                                <input v-bind:value="FormData.InvName" class="input_value" type="text"
                                    placeholder="点击选择相关信息">
                            </span>
                        </li>
                        <li class="list-group-item">
                            <span class="task_title">产品型号</span>
                            <span class="task_list">
                                <i class="icon-img"></i>
                                <input v-bind:value="FormData.ProductStd" type="text" readonly="true">
                            </span>
                        </li>
                        <li class="list-group-item">
                            <span class="task_title">订单数量</span>
                            <span class="task_list">
                                <input v-bind:value="FormData.OrderSum" readonly="readonly" type="text">
                            </span>
                        </li>
                        <li class="list-group-item">
                            <span class="task_title">任务数量</span>
                            <span class="task_list">
                                <input v-bind:value="FormData.TaskSum" readonly="readonly" type="text">
                            </span>
                        </li>
                        <li class="list-group-item">
                            <span class="task_title">完成数量</span>
                            <span class="task_list">
                                <input v-bind:value="FormData.OverSum" readonly="readonly" type="text">
                            </span>
                        </li>
                        <li class="list-group-item prolist">
                            报工工序
                            <span class="proitem" v-for="(item,index) in InvProcess" :key="index"
                                @click="clickAddBgColor(index)">
                                <button v-bind:class="{'clickBgColor':CurrSelectGx.GxSerial==item.GxSerial}"
                                    type="button">{{item.GxSerial}}.{{item.InvProcessItem}}</button>
                            </span>
                        </li>
                        <li class="list-group-item">
                            <span class="task_title">已报数量</span>
                            <span class="task_list">
                                <input v-bind:value="FormData.PlanNum" readonly="readonly" type="text">
                            </span>
                        </li>
                        <li class="list-group-item">
                            <span class="sum_title">合格数量</span>
                            <span class="sum_item">
                                <button type="button" :disabled="Hgs==0" @click="MinusFun">-</button>
                                <span class="sum_list">
                                    <label class="sum-img" for="Hgs"></label>
                                    <input id="Hgs" v-model="Hgs" readonly="readonly" maxlength="8" class="form-control"
                                           type="text" style="cursor: pointer" placeholder="点击弹出输入数字键盘">
                                </span>
                                <button type="button" @click="PlusFun">+</button>
                                <!--<button type="button" :disabled="Hgs==FormData.TaskSum" @click="PlusFun">+</button>-->
                            </span>
                        </li>
                        <li class="list-group-item">
                            <span class="sum_title">不良数量</span>
                            <span class="sum_item">
                                <button type="button" :disabled="Nhgs==0" @click="MinusFun2">-</button>
                                <span class="sum_list">
                                    <label class="sum-img" for="Nhgs"></label>
                                    <input id="Nhgs" v-model="Nhgs" readonly="readonly" maxlength="8" class="form-control"
                                           type="text" style="cursor: pointer;" placeholder="点击弹出输入数字键盘">
                                </span>
                                <button type="button" @click="PlusFun2">+</button>
                                <!--<button type="button" :disabled="Nhgs==FormData.TaskSum" @click="PlusFun2">+</button>-->
                            </span>
                        </li>
                        <li class="list-group-item">
                            <!--报工按钮部分-->
                            <div style="text-align: -moz-center;text-align: -webkit-center;text-align: center;">
                                <button v-on:click="SaveData()" style="width:190px;font-size: 1.5em" type="button"
                                    class="btn btn-success">报工</button>
                            </div>
                        </li>
                    </ul>
                    <!--操作记录部分-->
                    <div class="right_oper panel panel-default">
                        <ul class="nav nav-tabs">
                            <li class="active">
                                <a href="#OperateRecord" data-toggle="tab">操作记录</a>
                            </li>
                            <li>
                                <a href="#myCarousel" data-toggle="tab">操作指导</a>
                                <!-- <a href="#myCarousel" data-toggle="tab">操作指导</a> -->
                            </li>
                        </ul>
                        <div class="tab-content tabs">
                            <div class="tab-pane fade in active" id="OperateRecord">
                                <ul style="height:100%;overflow-y:auto;">
                                    <li style="font-size: 1.2em" v-for="(item,index) in OperateRecord"
                                        :style="{'color':item.Status?'blue':'red'}">
                                        {{item.Content}}
                                    </li>
                                </ul>
                            </div>
                            <div id="myCarousel" class="tab-pane fade carousel slide">
                                <!-- 轮播（Carousel）指标 -->
                                <ol class="carousel-indicators">
                                    <li data-target="#myCarousel" v-for="(item,index) in ImgSOPs" :data-slide-to="index"
                                        :class="index==0?'active':''"></li>
                                </ol>
                                <!-- 轮播（Carousel）项目 -->
                                <div class="carousel-inner">
                                    <div v-for="(item,index) in ImgSOPs" :class="index==0?'item active':'item'"
                                        style="width: 100%;height: 100%;">
                                        <img onclick="popup(this)" :src="item.src" alt="First slide"
                                            style="width: 100%;height: 100%;">
                                        <!-- <div class="carousel-caption">{{item.fileName}}</div> -->
                                    </div>
                                </div>
                                <!-- 轮播（Carousel）导航 -->
                                <a class="left" href="#myCarousel" role="button" data-slide="prev">
                                    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                                    <span class="sr-only">上一页</span>
                                </a>
                                <a class="right" href="#myCarousel" role="button" data-slide="next">
                                    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                                    <span class="sr-only">下一页</span>
                                </a>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
                <!--不良项部分-->
                <div class="tables">
                    <table class="table">
                        <caption class="" style="font-size:1.5em;text-align: center;border-bottom:none;width: 100%;font-weight: bold;">不良项明细</caption>
                        <!--<thead>-->
                            <!--<tr>-->
                                <!--<th>不良项名称</th>-->
                                <!--<th>不良项数量</th>-->
                            <!--</tr>-->
                        <!--</thead>-->
                        <tbody class="row">
                            <tr>
                                <td>不良项名称</td>
                                <td style="text-align: right;">不良项数量</td>
                            </tr>
                            <tr v-for="(item,index) in DefectiveItemData" class="row">
                                <td class="col-lg-8">{{item.ItemName}}</td>
                                <td class="col-lg-4">
                                    <div class="bad_div">
                                        <button type="button" class="dys_btn" :disabled="item.Qty==0" @click="BadItemFun(item)">-</button>
                                        <input :id="item.ItemID" v-model="item.Qty" readonly="readonly" type="text"
                                               placeholder="点击弹出输入数字键盘">
                                        <button type="button" class="dys_btn" @click="BadItemFun2(item)">+</button>
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>

            <!--报工记录部分-->
            <div class="record panel panel-default col-lg-12 col-md-12 col-sm-12">
                <div>
                    <h5 style="font-weight: bold;font-size: 1.5em;
                text-align: center;border-bottom:1px solid #DCDCDC;padding-top: 8px;padding-bottom: 8px">报工记录</h5>
                </div>
                <div class="table_scroll" style="overflow-x: auto;">
                    <table class="table">
                        <!--<caption style="font-weight: bold;font-size: 1.5em;-->
                        <!--text-align: center;border-bottom:1px solid #DCDCDC;padding-top: 8px;padding-bottom: 8px">报工记录</caption>-->
                        <thead>
                        <tr class="row">
                            <th class="col-lg-2">时间</th>
                            <!-- <th class="col-lg-1">工位</th> -->
                            <th class="col-lg-2">任务单号</th>
                            <th class="col-lg-2">产品名称</th>
                            <th class="col-lg-2">订单号</th>
                            <th class="col-lg-2">工序</th>
                            <th class="col-lg-1">合格数量</th>
                            <th class="col-lg-1">不良数量</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr class="row" v-for="(item,index) in PlanGather">
                            <td class="col-lg-1">{{item.SubTime}}</td>
                            <!-- <td class="col-lg-1">{{item.InvStd}}</td> -->
                            <td class="col-lg-2">{{item.TaskCode}}</td>
                            <td class="col-lg-1">{{item.InvName}}</td>
                            <td class="col-lg-2">{{item.OrderCode}}</td>
                            <td class="col-lg-2">{{item.InvProcessItem}}</td>
                            <td class="col-lg-1">{{item.Hgs}}</td>
                            <td class="col-lg-2">{{item.Nhgs}}</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>

            <!--图片弹窗部分-->
            <div class="dialog">
                <span><img src="/JG/Content/images/timg.jpg" alt="关闭"></span>
                <div class="dialog_img"><img src="" id="ShowImg" alt=""></div>
            </div>
        </div>

        <!--任务列表弹窗选项部分-->
        <div tabindex="-1" class="modal fade" id="myModal" role="dialog" aria-hidden="true" aria-labelledby="myModalLabel">
            <div class="modal-dialog">
                <div class="modal-content">
                    <!--头部-->
                    <div class="modal-header">
                        <div class="close_div">
                            <button class="close" aria-hidden="true" type="button" data-dismiss="modal">×</button>
                            <h4 class="modal-title" id="myModalLabel">生产任务列表</h4>
                        </div>
                        <div class="task_btn row">
                            <div class="search_list col-lg-12 col-md-12 col-sm-12" style="text-align: left">
                                <div class="search_item">
                                    <span>单据信息</span>
                                    <input v-model="FormData.ProTaskCode" id="ProTaskCode" type="text" placeholder="工单/订单/任务单号">
                                </div>
                                <div class="search_item">
                                    <span>产品信息</span>
                                    <input v-model="FormData.KeyWord" id="KeyWord" type="text" placeholder="产品编号/产品名称/型号">
                                </div>
                                <div class="shut_btn">
                                    <button class="btn btn-success" v-on:click="SearchLine()">搜索</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--内容部分-->
                    <div class="modal-body" id="tanchu" style="overflow-x: auto;overflow-y: auto;">
                        <div class="bs-example" data-example-id="hoverable-table">
                            <table class="table table-hover" id="btable">
                                <thead>
                                    <tr>
                                        <th>选择</th>
                                        <th>计划日期</th>
                                        <th>工单/订单/任务单号</th>
                                        <th>产品编码/名称/型号</th>
                                        <th>任务状态</th>
                                        <th>订单数量</th>
                                        <th>任务/完成数量</th>
                                    </tr>
                                </thead>
                                <tbody id="tableble">
                                    <tr id="1" v-for="(item,index) in TaskCodeGat">
                                        <td>
                                            <input class="radio_input" type="button" name="inputs" value="选择" v-on:click="SubData(item)" />
                                        </td>
                                        <td class="">{{item.ProductionDate}}</td>
                                        <td class="">{{item.WordCode}}</br>{{item.OrderCode}}</br>{{item.TaskCode}}</td>
                                        <td class="">{{item.InvCode}}</br>{{item.InvName}}</br>{{item.ProductStd}}</td>
                                        <td class="">{{item.Status}}</td>
                                        <td class="">{{item.OrderSum}}</td>
                                        <td class="">{{item.TaskSum}}/{{item.OverSum}}</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="/JG/Content/jquery/jquery-3.2.1.min.js"></script>
    <script src="/JG/Content/jquery/jquery-weui/js/jquery-weui.min.js"></script>
    <script src="/JG/Content/bootstrap.min.js"></script>
    <script src="/JG/Content/Utils.js?v=1"></script>
    <script src="/JG/Content/Common.js"></script>
    <script type="text/javascript" src="/JG/Content/AudioUtils.js"></script>
    <script src="/JG/Content/Numkeyboard.js"></script>
    <script src="/JG/Content/vue-v2.34.js"></script>
    <script src="/JG/Content/jquery/fastclick.js"></script>
    <script src="/JG/Content/bootstrap/bootbox/bootbox.min.js"></script>
    <script src="/JG/Content/bootstrap/bootbox/bootbox.locales.min.js"></script>


    <script type="text/javascript">
        //body赋值滚动条
        window.onload = function () {
            var BodyWidth = $(window).width();
            var BodyHeight = $(window).height();
            //body动态赋值滚动条
            if (BodyWidth > 1280) {
                //给Main的div加垂直滚动条
                var MainPageHeight = BodyHeight - 90;
                $(".sec_content").height(MainPageHeight);


                //任务列表弹窗
                var ModalBodyHeight = BodyHeight-108;
                $("#tanchu").height(ModalBodyHeight);

            } else if (BodyWidth < 1281 && BodyWidth > 1023) {
                var MainPageHeight = BodyHeight - 80;
                $(".sec_content").height(MainPageHeight);


                //任务列表弹窗
                var ModalBodyHeight = BodyHeight-108;
                $("#tanchu").height(ModalBodyHeight);

            } else if (BodyWidth < 1024 && BodyWidth > 767) {
                var MainPageHeight = BodyHeight - 85;
                $(".sec_content").height(MainPageHeight);

                //任务列表弹窗
                var ModalBodyHeight = BodyHeight-134;
                $("#tanchu").height(ModalBodyHeight);

            } else {
                var MainPageHeight = BodyHeight - 60;
                $(".sec_content").height(MainPageHeight);

                //任务列表弹窗
                var ModalBodyHeight = BodyHeight-134;
                $("#tanchu").height(ModalBodyHeight);
            }
        }

        $(function () {
            //获取当前用户的产线工位
            var stations = LocalUserInfo.GetUserInfo();
            //console.log(stations);
            //$("#stations").html(stations.ProductionLineName + " - " + stations.StationName);

            //这是关闭任务列表弹窗部分
            $("#close").click(function () {
                $(".shade").removeClass("shade_show");
            });

            //操作指导部分点击图片弹出当前图片
            function popup(e) {
                $("#ShowImg")[0].src = e.src;     //点击当前图片弹出大图片
                $(".dialog").addClass("dialog_show");
                //点击关闭按钮，图片弹窗关闭
                $(".dialog>span").click(function () {
                    //console.log(111);
                    $(".dialog").removeClass("dialog_show");
                })
            }

            //数字键盘部分弹窗绑定
            $("#Hgs").mynumkb();
            $("#Nhgs").mynumkb();
        });
    </script>

    <script type="text/javascript">
        var vmPage = new Vue({
            el: "#MainPage",
            data: {
                Hgs: "",  //合格数
                Nhgs: "",  //不良数
                curDate: "",   //当前时间的产线
                SubTime: "",    //保存当前时间
                ItemName: "",   //不良项名称
                Qty: "",   //不良项数量
                Status: "",   //该任务单号的状态
                Pictures: "",    ///保存操作指导部分请求回来的图片
                //totalNum:"",    //合格数与不良数总和
                // MinId:"",
                // PluId:"",
                FormData: {
                    ProdLine: "",   //产线名称
                    BgsjCxbm: "",    //产线编码
                    TaskCode: "",  //任务单号
                    InvCode: "",     //产品编码
                    InvName: "",   //产品名称
                    ProductStd: "",   //产品型号
                    WordCode: "",   //工单号
                    OrderCode: "",    //订单号
                    InvProcessItem: "",   //工序名称
                    GylxgsGxnum: "",    //工序编号
                    GxSerial: "",  //工序序号
                    GxID: "",  //工艺路线工序ID
                    SubType: "0",     //报工类型
                    OrderSum: "",   //订单数量
                    TaskSum: "",     //任务数量
                    OverSum: "",    //完成数量
                    ScrwID: "",    //生产任务ID
                    PlanNum: "",     //当前工序已报工数量
                    ProductionDate:"" ,  //计划日期
                    ProTaskCode:"",     //获取当前用户输入任务单号或订单号
                    KeyWord:"",         //获取当前用户输入产品关键字
                },
                ProcessesWorkID: $.getUrlParam("ProcessesWorkID"),//接收地址栏产品任务参数
                ProcessesWorkindex: $.getUrlParam("index"),//接收地址栏报工工序
                TaskCodeGat: [],  //任务单号信息集合
                InvProcess: [],   //工序与工艺工序路线ID集合
                DefectiveItemData: [],   //不良集合
                ScanCodeResult: "",    //保存获取数据失败弹窗变量
                OperateRecord: [],   //操作记录集合
                PlanGather: [],    //报工记录集合
                ImgSOPs: [],
                ProLineData: [],    // 产线集合
                CurrSelectGx: { GxSerial: "" } //当前选择的工序
            },
            mounted: function () {
                var currSelf = this;

                currSelf.ProLineStation();
                currSelf.ProdLineMethod();    //初始化
                if (currSelf.ProcessesWorkID) {
                    currSelf.GetProcessesWork();   //初始化
                }

                //给input绑定键盘输入事件
                //$("#BarCode").bind("keypress", currSelf.SearchBarCode);
                //绑定input获取聚焦事件
                //$("#BarCode").focus();
                //Utils.AutoBarCodeFocus();   //给input自动绑定聚焦方法
            },
            methods: {

                //操作记录方法
                SetOperateRecord: function (content, status) {
                    var currSelf = this;
                    var content = (new Date().Format("hh:mm:sss")) + ' ' + content;
                    currSelf.OperateRecord.splice(0, 0, { Content: content, Status: status });
                },

                //   工序部分点击选择显示样式方法
                clickAddBgColor: function (index) {
                    var currSelf = this;
                    currSelf.CurrSelectGx = currSelf.InvProcess[index];
                    currSelf.ImgSOPs = [];

                    if (currSelf.CurrSelectGx && currSelf.CurrSelectGx.Pictures.length > 0) {
                        var imgSOPs = JSON.parse(currSelf.CurrSelectGx.Pictures);
                        for (var index in imgSOPs) {
                            var itemPic = imgSOPs[index];
                            currSelf.ImgSOPs.push({ fileName: itemPic.name.split('.')[0], src: LocalConfig.SrvPath + itemPic.path });
                        }
                    }

                    currSelf.DefectiveItemData = [];  //再点击选中工序前先把之前选中的清空
                    $.showLoading();
                    //选择当前工序带出不良项接口
                    $.ajax({
                        type: "post",
                        async: true,
                        cache: true,
                        url: LocalConfig.SrvPath + "/jgmes/jgmesQmsAction!getBlList.action",
                        data: {
                            "gxId": currSelf.CurrSelectGx.GxID,
                        },
                        dataType: "json",
                        success: function (result) {
                            var retData = ReturnData(result);
                            console.log(retData);
                            if (retData.IsSuccess) {
                                if (retData.Data) {
                                    for (var i in retData.Data) {
                                        var element = retData.Data[i];
                                        currSelf.DefectiveItemData.push({
                                            ItemName: element.values.BLLX_BLLXMC,   //不良名称
                                            ItemID: element.values.BLLX_BLLXBM,
                                            Qty:"",
                                        });
                                    }
                                    //不良项数量部分的数字键盘绑定
                                    currSelf.$nextTick(function () {     //$nextTick方法是进行获取数据后，对更新后的hmtl做操作
                                        $.each(currSelf.DefectiveItemData, function (i, item) {
                                            $("#" + item.ItemID).mynumkb();
                                        });
                                    });
                                }else if(!retData.Data){
                                    var showMsg = "当前工序没有绑定相关不良项!";
                                    currSelf.SetOperateRecord(showMsg, false);
                                    $.toptip(showMsg, "warning");
                                }
                            }
                        },
                        error: function (xhr, status, errorThrow) {
                            console.error(status);
                            $.alert("获取不良项失败！");
                        },
                        complete: function () {
                            $.hideLoading();
                        }
                    });

                    $.showLoading();
                    //获取当前工序对应的已报工数接口
                    $.ajax({
                        type: "post",
                        async: true,
                        url: LocalConfig.SrvPath + "/jgmes/jgmesBgBatchAction!getAlreadyReportedNum.action",
                        data: {
                            "scrwId": currSelf.FormData.ScrwID,
                            "gxbh": currSelf.CurrSelectGx.GylxgsGxnum,
                        },
                        dataType: "json",
                        success: function (result) {
                            var retData = ReturnData(result);
                            if (retData.IsSuccess) {
                                currSelf.FormData.PlanNum = retData.Data;
                            }
                        },
                        error: function (xhr, status, errorThrown) {
                            $.alert("已报工数量请求失败!");
                        },
                        complete: function () {
                            $.hideLoading();
                        }
                    });
                },

                //点击弹窗选择按钮方法
                SubData: function (val) {
                    var currSelf = this;
                    //var submitData=currSelf.TaskCodeGat[currSelf.j];

                    $("#myModal").modal("hide");
                    currSelf.FormData.TaskCode = val.TaskCode;
                    currSelf.FormData.OrderCode = val.OrderCode;
                    currSelf.FormData.InvCode = val.InvCode;
                    currSelf.FormData.InvName = val.InvName;
                    currSelf.FormData.ProductStd = val.ProductStd;
                    currSelf.FormData.WordCode = val.WordCode;
                    currSelf.FormData.OrderSum = val.OrderSum;
                    currSelf.FormData.TaskSum = val.TaskSum;
                    currSelf.FormData.OverSum = val.OverSum;
                    currSelf.FormData.BgsjCxbm = val.BgsjCxbm;
                    currSelf.FormData.ScrwID = val.ScrwID;

                    currSelf.InvProcess = [];
                    $.showLoading();
                    //根据产品获取工序列表接口
                    $.ajax({
                        type: "post",
                        async: true,
                        cache: true,
                        url: LocalConfig.SrvPath + "/jgmes/commonAction!getGXList.action",
                        data: {
                            "userCode": LocalUserInfo.GetUserInfo().UserCode,
                            "mac": LocalUserInfo.GetUserInfo().Mac,
                            "cpCode": currSelf.FormData.InvCode,
                        },
                        dataType: "json",
                        success: function (ret) {
                            var retData = ReturnData(ret);
                            console.log(retData);
                            if (retData.IsSuccess && retData.Data) {
                                for (var i in retData.Data) {
                                    var element = retData.Data[i];
                                    currSelf.InvProcess.push({
                                        InvProcessItem: element.GYLXGX_GXNAME,
                                        GxID: element.GYLXGX_ID,
                                        GylxgsGxnum: element.GYLXGX_GXNUM,  // 工序编号
                                        GxSerial: element.SY_ORDERINDEX,
                                        Pictures: element.GYLXGX_SOP,   //操作指导图片集合
                                    })
                                }
                            } else if (!retData.Data){
                                var showMsg = "此任务单没有绑定工序!";
                                currSelf.SetOperateRecord(showMsg, false);
                                $.toptip(showMsg, "warning");
                            }
                        },
                        error: function (xhr, status, errorThrown) {
                            // console.error(status);
                            $.toptip(status, "error");
                        },
                        complete: function () {
                            $.hideLoading();
                        }
                    });
                },

                //获取产线任务全部信息方法
                ProdLineMethod: function () {
                    var currSelf = this;
                    $(".input_value,.icon-img").click(function () {
                        //清空原有加载数据
                        currSelf.TaskCodeGat = [];
                        currSelf.j = "";   //清空之前选中当前下标的任务列表数据
                        // $(".shade").addClass("shade_show");
                        $("#myModal").modal("show");
                        $.showLoading();
                        //任务单号接口
                        $.ajax({
                            type: "post",
                            async: true,
                            url: LocalConfig.SrvPath + "/jgmes/commonAction!getScrw.action",
                            data: {
                                "userCode": LocalUserInfo.GetUserInfo().UserCode,
                                "mac": LocalUserInfo.GetUserInfo().Mac,
                                "cxCode": currSelf.FormData.BgsjCxbm,
                                "curDate": currSelf.curDate,
                                "zt": "RWZT01,RWZT02,RWZT04"
                            },
                            dataType: "json",
                            success: function (result) {
                                var ret = ReturnData(result);
                                console.log(ret);
                                if (ret.IsSuccess) {
                                    if (ret.Data.length > 0) {
                                        for (var i in ret.Data) {
                                            var item = ret.Data[i];
                                            currSelf.TaskCodeGat.push({
                                                TaskCode: item.SCRW_RWDH,    //任务单号
                                                InvCode: item.SCRW_CPBH,     //产品编号
                                                WordCode: item.SCRW_GDHM,  //工单号
                                                OrderCode: item.SCRW_DDHM,  //订单号
                                                InvName: item.SCRW_NAME,  //产品名称
                                                ProductStd: item.SCRW_CPGG,   //产品型号
                                                OrderSum: item.SCRW_DDSL, //订单数
                                                TaskSum: item.SCRW_PCSL,  //任务数
                                                OverSum: item.SCRW_WCSL,  //完成数
                                                ScrwID: item.JGMES_PLAN_SCRW_ID,  //生产任务ID
                                                BgsjCxbm: item.SCRW_CXBM,  //产线编码
                                                Status: item.SCRW_RWZT_NAME,  //状态
                                                ProductionDate:item.SCRW_PCRQ   //计划日期
                                            });
                                        }
                                    }
                                }else if(!ret.Data){
                                    var showMsg = "该生产产线没有任务信息!";
                                    currSelf.SetOperateRecord(showMsg, false);
                                    $.toptip(showMsg, "warning");
                                }
                            },
                            error: function (xhr, status, errorThrown) {
                                // $.alert("任务单号请求失败!");
                                $.toptip(status, "error");
                            },
                            complete: function () {
                                $.hideLoading();
                            }
                        });
                    });
                },

                //获取全部产线信息方法
                ProLineStation: function () {
                    var currSelf = this;

                    //获取产线和工位接口
                    $.showLoading();
                    $.ajax({
                        type: "post",
                        async: true,   //异步
                        // url: LocalConfig.SrvPath + "/jgmes/commonAction!getCxGwList.action",
                        url: LocalConfig.SrvPath + "/jgmes/commonAction!getCxGwListFilterOutNoScrw.action",
                        data: {},
                        dataType: "json",
                        success: function (result) {
                            var retData = ReturnData(result);
                            //console.log(retData);
                            if (retData.IsSuccess) {
                                if (retData.Data) {
                                    currSelf.ProLineData = retData.Data;
                                    currSelf.FormData.BgsjCxbm = LocalUserInfo.GetUserInfo().ProductionLineCode;
                                }
                            } else if (!retData.Data) {
                                var showMsg = "未能找到产线信息";
                                $.toptip(showMsg, "warning");
                            }
                        },
                        error: function (xhr, status, errorThrow) {
                            console.error(status);
                            $.alert("获取产线失败!");
                        },
                        complete: function () {
                            $.hideLoading();
                        },
                    });
                },

                //另外选择产线时，页面之前信息全部清空方法
                ProductionLineChange: function () {    //产线更改
                    var currSelf = this;
                    //清空原有数据
                    currSelf.CurrSelectGx = { GxSerial: "" };
                    currSelf.DefectiveItemData = [];


                    currSelf.FormData.TaskCode = "";  //任务单号
                    currSelf.FormData.OrderCode = "";
                    currSelf.FormData.InvCode = "";     //产品编码
                    currSelf.FormData.InvName = "";   //产品名称
                    currSelf.FormData.ProductStd = "";   //规格
                    currSelf.FormData.WordCode = "";   //工单号
                    currSelf.FormData.OrderCode = "";    //订单号
                    currSelf.FormData.InvProcessItem = "";   //工序名称
                    currSelf.FormData.GylxgsGxnum = "";    //工序编号
                    currSelf.FormData.GxSerial = "";  //工序序号
                    currSelf.FormData.GxID = "";  //工艺路线工序ID
                    currSelf.FormData.SubType = "0";     //报工类型
                    currSelf.FormData.OrderSum = "";   //订单数量
                    currSelf.FormData.TaskSum = "";     //任务数量
                    currSelf.FormData.OverSum = "";    //完成数量
                    currSelf.FormData.ScrwID = "";    //生产任务ID
                    currSelf.FormData.PlanNum = "";     //当前工序已报工数量

                    currSelf.InvProcess = [];
                },

                //根据当前产品获取当前工序方法
                GetProcessesWork: function () {
                    var currSelf = this;

                    //获取当前生产任务的接口
                    $.ajax({
                        type: "post",
                        async: "true",
                        url: LocalConfig.SrvPath + "/jgmes/commonAction!getCurrentProductByScrwId.action",
                        data: {
                            "userCode": LocalUserInfo.GetUserInfo().UserCode,
                            "mac": LocalUserInfo.GetUserInfo().Mac,
                            "scrwId": currSelf.ProcessesWorkID, //任务生产ID
                        },
                        dataType: "json",
                        success: function (ret) {
                            //console.log(ret)
                            if (ret.IsSuccess) {
                                var val = ret.Data;

                                //currSelf.FormData.BgsjCxbm = val.BgsjCxbm;
                                currSelf.FormData.TaskCode = val.SCRW_RWDH;
                                currSelf.FormData.OrderCode = val.SCRW_DDHM;
                                currSelf.FormData.InvCode = val.SCRW_CPBH;
                                currSelf.FormData.InvName = val.SCRW_NAME;
                                currSelf.FormData.ProductStd = val.SCRW_CPGG;
                                currSelf.FormData.WordCode = val.SCRW_GDHM;
                                currSelf.FormData.OrderSum = val.SCRW_DDSL;
                                currSelf.FormData.TaskSum = val.SCRW_PCSL;
                                currSelf.FormData.OverSum = val.SCRW_WCSL;
                                currSelf.FormData.ScrwID = val.JGMES_PLAN_SCRW_ID;

                                currSelf.InvProcess = [];
                                $.showLoading();
                                //根据当前产品获取工序列表接口
                                $.ajax({
                                    type: "post",
                                    async: false,
                                    cache: true,
                                    url: LocalConfig.SrvPath + "/jgmes/commonAction!getGXList.action",
                                    data: {
                                        "userCode": LocalUserInfo.GetUserInfo().UserCode,
                                        "mac": LocalUserInfo.GetUserInfo().Mac,
                                        "cpCode": currSelf.FormData.InvCode,
                                    },
                                    dataType: "json",
                                    success: function (ret) {
                                        var retData = ReturnData(ret);
                                        if (retData.IsSuccess && retData.Data) {
                                            for (var i in retData.Data) {
                                                var element = retData.Data[i];
                                                currSelf.InvProcess.push({
                                                    InvProcessItem: element.GYLXGX_GXNAME,
                                                    GxID: element.GYLXGX_ID,
                                                    GylxgsGxnum: element.GYLXGX_GXNUM,  // 工序编号
                                                    GxSerial: element.SY_ORDERINDEX,
                                                    Pictures: element.GYLXGX_SOP,   //操作指导图片集合
                                                })
                                            }

                                            currSelf.$nextTick(function () {     //$nextTick方法是进行获取数据后，对更新后的hmtl做操作
                                                currSelf.clickAddBgColor(currSelf.ProcessesWorkindex);
                                            });
                                        } else if (!retData.Data) {
                                            var showMsg = "未能找到选择产品的工序信息";
                                            currSelf.SetOperateRecord(showMsg, false);
                                            $.toptip(showMsg, "warning");
                                        }
                                    },
                                    error: function (xhr, status, errorThrown) {
                                        console.error(status);
                                        $.alert("获取产品工序信息失败！");
                                    },
                                    complete: function () {
                                        $.hideLoading();
                                    }
                                });
                            }
                        },
                        error: function (xhr, status, errorThrown) {
                            $.alert("任务单号请求失败!");
                        },
                        complete: function () {
                            $.hideLoading();
                        }
                    })


                },

                //批量保存方法
                SaveData: function () {
                    var currSelf = this;
                    var msg;
                    if (!currSelf.FormData.InvName) {
                        msg = '请选择需要报工的产品';
                        $.toptip(msg, "warning");
                        currSelf.SetOperateRecord(msg, false);
                    } else if (!currSelf.CurrSelectGx.GxSerial) {
                        msg = '请选择需要报工的工序';
                        $.toptip(msg, "warning");
                        currSelf.SetOperateRecord(msg, false);
                    } else if (Number(currSelf.Hgs) <= 0 && Number(currSelf.Nhgs) <= 0) {
                        msg = '合格数量或不良数量不能为空或不小于等于零';
                        $.toptip(msg, "warning");
                        currSelf.SetOperateRecord(msg, false);
                    } else {
                        // if (((Number(currSelf.Hgs) + Number(currSelf.Nhgs) + Number(currSelf.FormData.PlanNum)) > Number(currSelf.FormData.TaskSum))) {
                        //     msg = '合格数量+不良数量+已报数量大于实际计划数量';
                        //     $.toptip(msg, "warning");
                        //     currSelf.SetOperateRecord(msg, false);
                        // }
                        $.confirm("确定要报工吗？", "操作提示", function () {
                            var jsonStr = JSON.stringify({
                                "BGSJ_BGLX": currSelf.FormData.SubType,
                                "BGSJ_CPMC": currSelf.FormData.InvName,
                                "BGSJ_CPGG": currSelf.FormData.ProductStd,
                                "BGSJ_GXMC": currSelf.CurrSelectGx.InvProcessItem,
                                "BGSJ_SL": Number(currSelf.Hgs),
                                "BGSJ_BLSL": currSelf.Nhgs,
                                "BGSJ_CPBH": currSelf.FormData.InvCode,
                                "BGSJ_CXBM": currSelf.FormData.BgsjCxbm,
                                "BGSJ_SCRWID": currSelf.FormData.ScrwID,
                                "BGSJ_GXBH": currSelf.CurrSelectGx.GylxgsGxnum,
                                "BGSJ_GWBH": LocalUserInfo.GetUserInfo().StationID,
                            });
                            //不良项子表数据
                            var jsonStrDetail = [];
                            for (var i in currSelf.DefectiveItemData) {
                                var element = currSelf.DefectiveItemData[i];
                                jsonStrDetail.push({
                                    "BGSJZB_BLMC": element.ItemName,
                                    "BGSJZB_BLBH": element.ItemID,
                                    "BGSJZB_SL": element.Qty
                                })
                            }

                            //报工记录保存对象
                            var record = {    //splice方法是从数组最前面插入一条新信息
                                SubTime: (new Date()).Format("hh:mm:sss"),
                                ProductStd: currSelf.FormData.ProductStd,
                                TaskCode: currSelf.FormData.TaskCode,
                                InvName: currSelf.FormData.InvName,
                                OrderCode: currSelf.FormData.OrderCode,
                                InvProcessItem: currSelf.CurrSelectGx.InvProcessItem,
                                Hgs: currSelf.Hgs,
                                Nhgs: currSelf.Nhgs,
                            };

                            //批量保存数据接口
                            $.showLoading();
                            $.ajax({
                                type: "post",
                                async: false,
                                cache: true,
                                url: LocalConfig.SrvPath + "/jgmes/jgmesBgBatchAction!doJsonSave.action",
                                data: {
                                    "userCode": LocalUserInfo.GetUserInfo().UserCode,
                                    "jsonStr": jsonStr,
                                    "jsonStrDetail": JSON.stringify(jsonStrDetail),
                                    "wordcode": currSelf.FormData.WordCode,
                                },
                                dataType: "json",
                                success: function (result) {
                                    var retData = ReturnData(result);
                                    if (retData.IsSuccess) {
                                        msg = "任务单号:" + currSelf.FormData.TaskCode + ",报工成功";
                                        currSelf.SetOperateRecord(msg, true);
                                        //清空原有数据
                                        currSelf.CurrSelectGx = { GxSerial: "" };
                                        currSelf.DefectiveItemData = [];
                                        currSelf.Hgs = "";
                                        currSelf.Nhgs = "";
                                        currSelf.FormData.PlanNum = "";
                                        //报工完后添加一条报工记录
                                        currSelf.PlanGather.splice(0, 0, record);
                                    }
                                    else {
                                        msg = "报工失败，失败原因:" + retData.message;
                                        currSelf.SetOperateRecord(msg, false);
                                    }
                                },
                                error: function (xhr, status, errorThrow) {
                                    //console.error(status);
                                    $.alert("批量保存数据失败！");
                                },
                                complete: function () {
                                    $.hideLoading();
                                }
                            });
                        });
                    }
                },

                //点击工单列表弹窗搜索按钮方法
                SearchLine:function(){
                    var currSelf = this;

                    if(!LocalUserInfo.GetUserInfo().ProductionLineCode){
                        //bootbox.alert("请先绑定当前产线!");
                        $("#ProTaskCode").focus();  //点击搜索按钮时，搜索框获取聚焦
                    }
                    // else if(!currSelf.FormData.ProTaskCode && !currSelf.FormData.KeyWor){
                    //     bootbox.alert("请先输入需要搜索的内容!");
                    //     $("#KeyWord").focus();  //点击搜索按钮时，搜索框获取聚焦
                    // }
                    else{
                        currSelf.TaskCodeGat=[];
                        $.showLoading();
                        //任务单号接口
                        $.ajax({
                            type: "post",
                            async: true,
                            url: LocalConfig.SrvPath + "/jgmes/commonAction!getScrw.action",
                            // url: LocalConfig.SrvPath + "/jgmes/commonAction!getScrwByGX.action",
                            data: {
                                "userCode": LocalUserInfo.GetUserInfo().UserCode,
                                "mac": LocalUserInfo.GetUserInfo().Mac,
                                "cxCode": currSelf.FormData.BgsjCxbm,   //产线编码
                                "curDate": currSelf.curDate,    //当前产线的时间
                                "noLike":currSelf.FormData.ProTaskCode,    //获取当前用户输入任务单号
                                "cpLike":currSelf.FormData.KeyWord,     //获取当前用户输入产品关键字
                            },
                            dataType: "json",
                            success: function (result) {
                                var ret = ReturnData(result);
                                console.log(ret);
                                if (ret.IsSuccess) {
                                    if (ret.Data.length > 0) {
                                        for (var i in ret.Data) {
                                            var item = ret.Data[i];
                                            currSelf.TaskCodeGat.push({
                                                TaskCode: item.SCRW_RWDH,    //任务单号
                                                InvCode: item.SCRW_CPBH,     //产品编号
                                                WordCode: item.SCRW_GDHM,  //工单号
                                                OrderCode: item.SCRW_DDHM,  //订单号
                                                InvName: item.SCRW_NAME,  //产品名称
                                                ProductStd: item.SCRW_CPGG,   //产品型号
                                                OrderSum: item.SCRW_DDSL, //订单数
                                                TaskSum: item.SCRW_PCSL,  //任务数
                                                OverSum: item.SCRW_WCSL,  //完成数
                                                ScrwID: item.JGMES_PLAN_SCRW_ID,  //生产任务ID
                                                BgsjCxbm: item.SCRW_CXBM,  //产线编码
                                                Status: item.SCRW_RWZT_NAME,  //状态
                                                ProductionDate:item.SCRW_PCRQ   //计划日期
                                            });
                                        }
                                    }
                                }else{
                                    $.toptip("该生产产线没有任务列表信息!", "warning");
                                }
                            },
                            error: function (xhr, status, errorThrown) {
                                // console.log(status);
                                $.toptip("该生产产线没有任务列表信息!", "error");
                            },
                            complete: function () {
                                $.hideLoading();
                            }
                        });
                    }
                },

                //点击合格数中的减号按钮方法
                MinusFun:function(){
                    var currSelf = this;
                    if(currSelf.Hgs > 0){
                        currSelf.Hgs--;
                    }
                },

                //点击合格数的加号按钮方法
                PlusFun:function(){
                    var currSelf = this;
                    if(currSelf.Hgs >= 0){
                        currSelf.Hgs++;
                    }
                    // if(currSelf.Hgs >= 0){
                    //     currSelf.Hgs++;
                    // }else if(!currSelf.FormData.TaskSum){
                    //     // currSelf.Hgs="";
                    //     $("#Hgs").val("");
                    //     if(currSelf.Hgs < currSelf.FormData.TaskSum){
                    //         currSelf.Hgs++;
                    //     }
                    // }
                },

                //点击不良数中的减号按钮方法
                MinusFun2:function(){
                    var currSelf = this;
                    if(currSelf.Nhgs > 0){
                        currSelf.Nhgs--;
                    }
                },

                //点击不良数中的加号按钮方法
                PlusFun2:function(){
                    var currSelf = this;
                    if(currSelf.Nhgs >= 0){
                        currSelf.Nhgs++;
                    }else if(!currSelf.FormData.TaskSum){
                        // currSelf.Nhgs="";
                        $("#Nhgs").val("");
                        if(currSelf.Nhgs < currSelf.FormData.TaskSum){
                            currSelf.Nhgs++;
                        }
                    }
                },

                //点击不良项部分的减号按钮方法
                BadItemFun:function(item){
                    // console.log(item);
                    // console.log(item.Qty);
                    if(item.Qty>0){
                        item.Qty--;
                    }
                    // else{
                    //     bootbox.alert("已是最小值,请先输入大于0的值");
                    // }
                },

                //点击不良项部分的减号按钮方法
                BadItemFun2:function(item){
                    item.Qty++;
                },
            }
        })
    </script>
</body>

</html>